﻿using GodSystemDAL;
using GodSystemModel;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GodSystemBLL
{
    public class SupplierBLL
    {
        private static SupplierDAL supplierDAL = new SupplierDAL();

        public SupplierModel GetSupplierById(uint id)
        {
            SupplierModel supplier = new SupplierModel();
            supplier.Id = id;
            MySqlDataReader supplierData = supplierDAL.GetSupplierById(supplier);
            SupplierModel supplierInfo = null;
            if (supplierData.HasRows)
            {
                supplierInfo = new SupplierModel();
                supplierData.Read();
                supplierInfo.Id = supplierData.GetUInt32(0);
                supplierInfo.SupplierName = supplierData.GetString(1);
                supplierInfo.Telphone = supplierData.GetString(2);
                supplierInfo.Phone = supplierData.GetString(3);
                supplierInfo.Country = supplierData.GetString(4);
                supplierInfo.Province = supplierData.GetString(5);
                supplierInfo.City = supplierData.GetString(6);
                supplierInfo.Area = supplierData.GetString(7);
                supplierInfo.Address = supplierData.GetString(8);
                supplierInfo.CreateTime = supplierData.GetDateTime(9);
                supplierInfo.SupplierStatus = supplierData.GetInt32(10);
                supplierInfo.CreateUser = supplierData.GetString(11);
            }
            return supplierInfo;
        }
    }
}
